{% extends "oa/base.html" %}
{% load i18n static %}
{% block title %} 原料入库明细 {% endblock %}
{% block this_css %}
    <style>
        tbody > tr > td {
            white-space: nowrap
        }
    </style>
{% endblock %}
{% block content %}
    <section class="panel">
        <div class="panel-body">
            <form method="get" action="{{ request.path }}" class="form-inline">
                <div class="form-group">
                    <label for="supplier_id">供应商:</label>
                    <select name="supplier_id" id="supplier_id" class="form-control">
                        <option value="">-----</option>
                        {% for s in suppliers %}
                        {% ifequal s.pk|escape request.GET.supplier_id %}
                        <option value="{{ s.pk }}" selected>{{ s.name }}</option>
                        {% else %}
                        <option value="{{ s.pk }}">{{ s.name }}</option>
                        {% endifequal %}
                        {% endfor %}
                    </select>
                </div>
                <div class="form-group">
                    <label for="date_start">开始日期:</label>
                    <input type="text" class="form-control" name="date_start" value="{{ request.GET.date_start }}"
                           id="date_start" placeholder="yyyy-mm-dd" data-date-format="yyyy-mm-dd">
                </div>
                <div class="form-group">
                    <label for="date_end">截止日期:</label>
                    <input type="text" class="form-control" name="date_end" value="{{ request.GET.date_end }}"
                           id="date_end" placeholder="yyyy-mm-dd" data-date-format="yyyy-mm-dd">
                </div>
                <button type="submit" class="btn btn-info">重新统计</button>
                <a target="_blank"
                   href="?excel=1&date_start={{ request.GET.date_start }}&date_end={{ request.GET.date_end }}">
                    <span type="submit" class="btn btn-default">导出EXCEL</span>
                </a>
            </form>
        </div>
    </section>
    <section class="panel">
        <div class="panel-body table-responsive">
            <table class="table table-striped table-bordered table-responsive">
                <thead>
                    <tr>
                        <th colspan="15"><h3>原料入库明细</h3></th>
                    </tr>
                    <tr>
                        <th>ID</th>
                        <th>下单日期</th>
                        <th>入库单号</th>
                        <th>采购单号</th>
                        <th>原料类别</th>
                        <th>物料编码</th>
                        <th>原料名称</th>
                        <th>供应商</th>
                        <th>单位</th>
                        <th>包装规格</th>
                        <th>购进数量</th>
                        <th>到货数量</th>
                        <th class="text-right">总价/元</th>
                        <th class="text-right">到货金额/元</th>
                        <th class="text-right">单价/元</th>
                        <th class="text-right">单位成本/元</th>
                        <th>预计到货时间</th>
                        <th>实际到货时间</th>
                    </tr>
                </thead>
                <tbody>
                    {% for row in rows %}
                    <tr>
                        <td>{{ row.pk }}</td>
                        <td>{{ row.related_order__related_purchase_order__order_date|date:'Y-m-d' }}</td>
                        <td>{{ row.related_order__code }}</td>
                        <td>{{ row.related_order__related_purchase_order__code }}</td>
                        <td>{{ row.material__material_category__name }}</td>
                        <td>{{ row.material__code }}</td>
                        <td>{{ row.material__name }}</td>
                        <td>{{ row.related_order__related_purchase_order__supplier__name }}</td>
                        <td>{{ row.unit }}</td>
                        <td>{{ row.material_batch__package_unit__display }}</td>
                        <td class="text-right">{{ row.related_purchase_detail__amount|floatformat:'2' }}</td>
                        <td class="text-right">{{ row.amount|floatformat:'2' }}</td>
                        <td class="text-right">{{ row.related_purchase_detail__price|floatformat:'2' }}</td>
                        <td class="text-right">{{ row.current_price|floatformat:'2' }}</td>
                        <td class="text-right">{{ row.unit_price|floatformat:'2' }}</td>
                        <td class="text-right">{{ row.unit_cost|floatformat:'2' }}</td>
                        <td>{{ row.related_purchase_detail__exp_record_date|date:'Y-m-d' }}</td>
                        <td>{{ row.related_order__record_date|date:'Y-m-d' }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            <div class="text-right">
                {% include 'pagination.html' %}
            </div>
        </div>
    </section>
{% endblock %}
